//
//  ViewController.swift
//  下拉刷新
//
//  Created by 452608533 on 16/7/25.
//  Copyright © 2016年 452608533. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    override func loadView() {
        view = self.tableView
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        setupUI()

    }
    
    func setupUI() {

        xjRefreshControl.addTarget(self, action: "refreshAction", forControlEvents: UIControlEvents.ValueChanged)
        
        self.tableView.addSubview(xjRefreshControl)
        
    }
    
    func refreshAction(){
        
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (Int64)(3 * NSEC_PER_SEC)), dispatch_get_main_queue()) { () -> Void in
            self.xjRefreshControl.endRefreshing()
        }
    }

    lazy var tableView:UITableView = UITableView()
    //懒加载控件
    private lazy var xjRefreshControl: XJRefreshControl = XJRefreshControl()
}

